//
// Created by steven on 2017/3/9.
// Copyright (c) 2017 steven. All rights reserved.
//

#import "GMQrCodeView.h"


@implementation GMQrCodeView

- (id)init {
    self = [super init];
    if (self) {
        // hint label
        [self addSubview:self.hintLabel];

        // qr image view
        [self addSubview:self.qrImageView];
    }

    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];

    [self.hintLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0];
    [self.hintLabel autoAlignAxisToSuperviewAxis:ALAxisVertical];

    [self.qrImageView autoAlignAxisToSuperviewAxis:ALAxisVertical];
    [self.qrImageView autoSetDimensionsToSize:CGSizeMake(self.frame.size.width*0.8, self.frame.size.width*0.8)];
    [self.qrImageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.hintLabel withOffset:10];

}
#pragma mark - hint label
- (UILabel *)hintLabel {
    if (!_hintLabel) {
        _hintLabel = [[UILabel alloc] init];
        _hintLabel.text = @"请下载守护侠客户端扫描下方二维码";
        _hintLabel.textColor = HINT_COLOR;
    }

    return _hintLabel;
}

#pragma mark - qr image view
- (UIImageView *)qrImageView {
    if (!_qrImageView) {
        _qrImageView = [[UIImageView alloc] init];
    }

    return _qrImageView;
}
@end